import { Injectable } from "@nestjs/common";
import * as bcrypt from "bcrypt";
import { nanoid } from "nanoid";

@Injectable()
export class CryptoService {
    async hashPassword(password: string): Promise<string> {
        return await bcrypt.hash(password, 10);
    }

    async checkPasswordHash(password: string, hash: string): Promise<boolean> {
        return await bcrypt.compare(password, hash);
    }

    generateNanoID(): string {
        return nanoid(12);
    }
}
